<?php
header('content-type:text/html;charset=utf-8');
$link=mysqli_connect('localhost','root','');
if (!$link){
    die('连接数据库失败!'.mysqli_error($link));
}

mysqli_query($link,'set names utf8');
mysqli_query($link,'use `itcast`');

$where='';
if(isset($_GET['keyword'])){
    $keyword = $_GET['keyword'];
    $keyword = mysqli_real_escape_string($link,$keyword);
    $where = "where e_name like '%$keyword%'";}

$sql="select* from `emp_info` $where";
$res=mysqli_query($link,$sql);
//if (!$res)  die(mysqli_error());
$emp_info=array();
while($row=mysqli_fetch_assoc($res)){
    $emp_info[]=$row;
}
define('APP','itcast');
require './list_html.php';